package cn.edu.ctbu.lddweb.service.lmpl;

import cn.edu.ctbu.lddweb.service.ClassService;
import cn.edu.ctbu.lddweb.mapper.ClassMapper;
import cn.edu.ctbu.lddweb.pojo.Class;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 班级管理实现层
 */
@Service
public class ClassServicelmpl implements ClassService {

    @Autowired
    private ClassMapper classMapper;

    @Override
    public List<Class> selectList(Class aclass) {
        return classMapper.selectList(aclass);
    }

    /**
     * 检查是否唯一
     * @param aclass
     * @return
     */
    @Override
    public Boolean checkClassUnique(Class aclass) {
        int id = aclass.getId()==0?-1:aclass.getId();
        Class info = classMapper.checkClassUnique(aclass);
        if(info!=null&&info.getId()!=id){
            return true;
        }
        return false;
    }

    @Override
    public Class findID(@Param("id") int id) {
        return classMapper.findID(id);
    }

    @Override
    public int insertClass(Class class1) {
        return classMapper.insertClass(class1);
    }

    @Override
    public int updateClass(Class class1) {
        return classMapper.updateClass(class1);
    }

    @Override
    public int deleteClass(String id) {
        return classMapper.deleteClass(id);
    }
}
